<?php

class db{
   
    public function __construct(){
        $conn = mysql_connect("localhost","root","root");
        if(!$conn){
            echo "连接失败";
            exit;
        }
       mysql_select_db("php",$conn);
       mysql_query("SET NAMES UTF8",$conn);
    }
    
    public function query($sql){
        return mysql_query($sql);
    }
}

$conn = new db();
$result = $conn->query("select * from user");
while ($row = mysql_fetch_object($result)){
    $rows[] = $row;
   // echo $row['username'].'=========';
}
foreach ($rows as $r){
    print_r($r->username);
}
var_dump($rows);
echo count($rows);
print_r($rows);














